package io.seata.sample.service;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;
import io.seata.sample.entity.Order;

import java.math.BigDecimal;

/**
 * @author zengpeng
 */
@LocalTCC
public interface OrderTCCService {

    /**
     * 创建订单
     * @param order
     * @return
     */
    @TwoPhaseBusinessAction(name = "orderTccAction", commitMethod = "commitCreate", rollbackMethod = "rollbackCreate")
    boolean prepareCreate(BusinessActionContext businessActionContext, @BusinessActionContextParameter(paramName = "orderId") Long id, Order order);

    // 第二阶段 - 提交
    boolean commitCreate(BusinessActionContext businessActionContext);

    // 第二阶段 - 回滚
    boolean rollbackCreate(BusinessActionContext businessActionContext);

}
